<!--- ==================================================
NAME:	crt_baccount_ndc.cfm
DESC:	File used to create an account.
=================================================== --->
<cfsetting enablecfoutputonly="yes">

<!--- default data --->
<cfparam name="arguments.customerid" type="any" default="">
<cfparam name="arguments.contactid" type="any" default="">
<cfparam name="arguments.type" type="any" default="">
<cfparam name="arguments.prefix" type="any" default="">
<cfparam name="arguments.first_name" type="any" default="">
<cfparam name="arguments.midinit" type="any" default="">
<cfparam name="arguments.last_name" type="any" default="">
<cfparam name="arguments.company_department" type="any" default="">
<cfparam name="arguments.b_company_name" type="any" default="">
<cfparam name="arguments.b_address1" type="any" default="">
<cfparam name="arguments.b_address2" type="any" default="">
<cfparam name="arguments.b_city" type="any" default="">
<cfparam name="arguments.b_state" type="any" default="">
<cfparam name="arguments.b_zip" type="any" default="">
<cfparam name="arguments.b_geo_code" type="any" default="">
<cfparam name="arguments.b_country" type="any" default="">
<cfparam name="arguments.b_phone" type="any" default="">
<cfparam name="arguments.b_ext" type="any" default="">
<cfparam name="arguments.alt_phone" type="any" default="">
<cfparam name="arguments.alt_ext" type="any" default="">
<cfparam name="arguments.fax_phone" type="any" default="">
<cfparam name="arguments.email" type="any" default="">
<cfparam name="arguments.source" type="any" default="web">
<cfparam name="arguments.account_active" type="any" default="">
<cfparam name="arguments.tax_resale_number" type="any" default="">
<cfparam name="arguments.tsr_own" type="any" default="">
<cfparam name="arguments.flag_esf" type="any" default="Y"> <!--- ESF now handles Advertising Opt-Out - "Y" means yes to broadcast --->
<cfparam name="arguments.flag_nmail" type="any" default="Y"> <!--- NMail handles Confirmation Opt-Out - "Y" means no email should be send --->

<!--- clean data --->
<cfset arguments.first_name="#application.string_validation.replace_and(arguments.first_name)#">
<cfset arguments.last_name="#application.string_validation.replace_and(arguments.last_name)#">
<cfset arguments.company_department="#application.string_validation.replace_and(arguments.company_department)#">
<cfset arguments.b_company_name="#application.string_validation.replace_and(arguments.b_company_name)#">
<cfset arguments.b_address1="#application.string_validation.replace_and(arguments.b_address1)#">
<cfset arguments.b_address2="#application.string_validation.replace_and(arguments.b_address2)#">
<cfset arguments.b_city="#application.string_validation.replace_and(arguments.b_city)#">
<cfset arguments.b_state="#application.string_validation.replace_and(arguments.b_state)#">
<cfset arguments.b_phone="#application.string_validation.only_numeric(arguments.b_phone)#">
<cfset arguments.alt_phone="#application.string_validation.only_numeric(arguments.alt_phone)#">
<cfset arguments.fax_phone="#application.string_validation.only_numeric(arguments.fax_phone)#">


<!--- build xml statement --->
<cfscript>
xi_namespace='#trim(application.xi_namespace)#:CUSTOMER:CreateCustomer';
xi_interface='CreateCustomer_OB';
xml = '<xtiinput>
	<inputheader>
		<actionset>
			<action>crt_baccount_ndc</action>
		</actionset>
	</inputheader>
	<inputdata> 
		<customer>
			<system>#variables.system#</system>
			<customerid>#Ucase(arguments.customerid)#</customerid>
			<contactid>#Ucase(arguments.contactid)#</contactid>
			<type>#Ucase(arguments.type)#</type>
			<prefix>#Ucase(arguments.prefix)#</prefix>
			<first_name>#Ucase(arguments.first_name)#</first_name>
			<midinit>#Ucase(arguments.midinit)#</midinit>
			<last_name>#Ucase(arguments.last_name)#</last_name>
			<attnfirst>#Ucase(arguments.first_name)#</attnfirst>
			<attnlast>#Ucase(arguments.last_name)#</attnlast>
			<company_department>#Ucase(arguments.company_department)#</company_department>
			<billing>
				<company_name>#Ucase(arguments.b_company_name)#</company_name>
				<address_1>#Ucase(arguments.b_address1)#</address_1>
				<address_2>#Ucase(arguments.b_address2)#</address_2>
				<city>#Ucase(arguments.b_city)#</city>
				<state>#Ucase(arguments.b_state)#</state>
				<zip>#Ucase(arguments.b_zip)#</zip>
				<geo_code>#Ucase(arguments.b_geo_code)#</geo_code>
				<country>#Ucase(arguments.b_country)#</country>
				<phone>#rereplace(arguments.b_phone, '[^0-9]', '', 'all')#</phone>
			</billing>
			<ext>#Ucase(arguments.b_ext)#</ext>
			<alt_phone>#rereplace(arguments.alt_phone, '[^0-9]', '', 'all')#</alt_phone>
			<alt_ext>#Ucase(arguments.alt_ext)#</alt_ext>
			<fax_phone>#rereplace(arguments.fax_phone, '[^0-9]', '', 'all')#</fax_phone>
			<email>#arguments.email#</email>
			<source>#Ucase(arguments.source)#</source>
			<account_active>#Ucase(arguments.account_active)#</account_active>
			<tax_resale_number>#Ucase(arguments.tax_resale_number)#</tax_resale_number>
			<tsr_own>#Ucase(arguments.tsr_own)#</tsr_own>
			<esf>#arguments.flag_esf#</esf>
			<no_email>#arguments.flag_nmail#</no_email>
		</customer>
	</inputdata>
</xtiinput>';
</cfscript>